package view;

import controller.Controller;
import model.DataSource;
import controller.ActionLis;

import javax.swing.*;
import java.awt.*;

public class RegisterJPanel extends JPanel{
    public  JTextField usernameField = new JTextField();
    public JPasswordField passwordField = new JPasswordField();
    public   JPasswordField passwordFieldAgain = new JPasswordField();
    private Controller controller;
    public JButton registerButton;
    public ActionLis actionLis=new ActionLis();
    public RegisterJPanel(Controller controller) {
        this.controller=controller;
        setLayout(null);
        setPreferredSize(new Dimension(1200,800));
        JLabel titleLabel = new JLabel("请注册！！");
        titleLabel.setBounds(400, 130, 300, 30);
        titleLabel.setFont(new Font(Font.DIALOG, Font.BOLD, 30));
        titleLabel.setForeground(Color.BLACK); // 设置字体颜色为黄色
        add(titleLabel);

        JLabel usernameLabel = new JLabel("用户名:");
        usernameLabel.setBounds(350, 280, 100, 30);
        usernameLabel.setFont(new Font(Font.DIALOG, Font.BOLD, 20));
        usernameLabel.setForeground(Color.BLACK); // 设置字体颜色为黄色
        add(usernameLabel);

        usernameField = new JTextField();
        usernameField.setBounds(430, 280, 150, 30);
        add(usernameField);

        JLabel passwordLabel = new JLabel("密码:");
        passwordLabel.setBounds(370, 330, 100, 30);
        passwordLabel.setFont(new Font(Font.DIALOG, Font.BOLD, 20));
        passwordLabel.setForeground(Color.BLACK); // 设置字体颜色为黄色
        add(passwordLabel);

        passwordField = new JPasswordField();
        passwordField.setBounds(430, 330, 150, 30);
        add(passwordField);

        JLabel passwordLabelAgain = new JLabel("确认密码:");
        passwordLabelAgain.setBounds(330, 380, 100, 30);
        passwordLabelAgain.setFont(new Font(Font.DIALOG, Font.BOLD, 20));
        passwordLabelAgain.setForeground(Color.BLACK); // 设置字体颜色为黄色
        add(passwordLabelAgain);

        passwordFieldAgain = new JPasswordField();
        passwordFieldAgain.setBounds(430, 380, 150, 30);
        add(passwordFieldAgain);

        registerButton = new JButton("确认注册");
        registerButton.setBounds(540, 440, 140, 50);
        add(registerButton);
        registerButton.addActionListener(actionLis);
        registerButton.setActionCommand("yesRegister");
    }

    @Override
    protected void paintComponent(Graphics g) {
        super.paintComponent(g);
        g.drawImage(DataSource.backGroundImage, 0, 0, 1200, 800, null);
       /* g.drawImage(DataSource.yesRegisterImage,450, 500, 140, 80, null);*/

    }
}
